import request from "@/utils/request.js"
const state = {
	spuList:{},
	skuList:{},
	userPreview:{},
	previewTotal:0
}
const mutations = {
	SET_SPULIST(state,spuList){
		state.spuList = spuList
	},
	SET_SKULIST(state,skuList){
		state.skuList = skuList
	},
	SET_USERPREVIEW(state,userPreview){
		state.userPreview = userPreview
	},
	SET_PREVIEWTOTAL(state,previewTotal){
		state.previewTotal = previewTotal
	}
	
}
const actions = {
	async getspuList({commit},ids = 1001628){
		let res = await request("product/spus?ids="+ids)
		commit("SET_SPULIST",res.data.list[0])
	},
	async getskuList({commit},ids = 100162801){
		let res = await request("product/skus?ids="+ids)
		commit("SET_SKULIST",res.data.list[0])
	},
	async getuserPreview({commit},ids = 1001628){
		let res = await request("comment/open/v1/preview?spu_id="+ids)
		commit("SET_PREVIEWTOTAL",res.data.total)
		commit("SET_USERPREVIEW",res.data.list[0])
	},
	
}
const getters = {
}

export default {
	namespaced: true,
	state,
	mutations,
	actions,
	getters
}
